package com.heaven.adminServer.adminController.minio;

import com.heaven.service.minio.MinIoService;
import com.heaven.utils.R;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("heaven-server")
public class GetObjectController {
    @Resource
    private MinIoService minIoService;

    @GetMapping("/get-link")
    public R getLink(@RequestParam("bucket") String bucket,
                     @RequestParam("objectName") String objectName){
        String link = minIoService.getObjectUrl(bucket, objectName, 1, TimeUnit.DAYS);

        return R.ok().put("data", link);
    }
}
